rows
Select * from table LIMIT; # return the first five rows
1. when the offset value is small.Select * from yanxue8_visit limit 10, 10
Run multiple times and keep the time between 0.0004 and 0.0005Select * From yanxue8_visit Where vid> = (Select vid From yanxue8_visit Order By vid limit 10, 1) Limit 10
Run multiple times, and the time is kept between 0.0005-0.0006, mainly 0.0006Conclusion: When the offset is small, it is better to use limit directly. This is obviously the cause of subquery.
directly. This is obviously the cause of subquery.
2. When the offset value is large
Select * from yanxue8_visit limit, 10
Run multiple times and keep the time at around 0.0187
Select * From yanxue8_visit Where vid> = (
Select vid From yanxue8_visit Order By vid limit, 1
) Limit 10
Run multiple times, with a time of around 0.0061, only 1/3 of the former. It can be predicted that the larger the offset, the higher the latter.
Attached Original:
Select * from table LIMIT 5, 10; # return da
yanxue8_visit Order By vid limit 10000,1
) limit 10
Run multiple times, with a time of around 0.0061, only 1/3 of the former. It can be predicted that the larger the offset, the higher the latter.
Attached Original:
Select * from table LIMIT 5, 10; # return data in rows 6-15
Select * from table LIMIT 5; # Return the first five rows
Select * from table LIMIT; # Return the first five rows
Performance Optimization:
Based on the high performance of Mysql limit in MySQL5.0, I have a new under
SQL limit to implement TENS data volume paging
SELECT * FROM Table LIMIT 5, 10; #返回第6-15 rows of dataSELECT * FROM table LIMIT 5; #返回前5行SELECT * FROM table LIMIT 0, 5; #返回前5行
Performance optimization:
Based on the high performance of limit in MySQL5.0, I have a new understanding of data paging.
1.Select * FROM Cyclopedia Where id>= (Select Max (ID) from (Select ID from Cyclopedia order by ID lim
specified, it indicates that the maximum number of record rows is returned:Mysql> SELECT * FROM table LIMIT 5; // retrieve the first five record rows // In other words, LIMIT n is equivalent to LIMIT 0, n. Note the differences between limit 10 and limit 9 and 1: for example, 1.Select * From cyclopedia Where ID> = (Select Max (ID) From (Select ID From cyclopedia Order By ID limit 90001) As tmp) Limit 100; 2
records FROM 6 to 15 rows.// To retrieve all record rows from an offset to the end of the record set, you can specify the second parameter-1:Mysql> SELECT * FROM table LIMIT 95,-1; // retrieves 96-last Records.// If only one parameter is specified, it indicates the maximum number of record rows returned:Mysql> SELECT * FROM table LIMIT 5; // retrieve the first five record rows// In other words, LIMIT n is equivalent to LIMIT 0, n.Note the differences between limit 10 and limit 9 and 1:For examp
Select * from Table limit 5, 10; # return data in rows 6-15
Select * from Table limit 5; # Return the first five rows
Select * from Table limit; # Return the first five rows
Performance Optimization:Based on the high performance of limit in mysql5.0, I have a new understanding of data paging.
1.Select * From Cyclopedia where ID> = (Select max (ID) from (Select ID from Cyclopedia order by ID limit 90001) As
is better to use limit directly. This is obviously the cause of subquery.2. When the offset value is large.Select * From yanxue8_visit limit, 10Run multiple times and keep the time at around 0.0187Select * From yanxue8_visit where vid> = (Select vid from yanxue8_visit order by VID limit, 1) Limit 10Run multiple times, with a time of around 0.0061, only 1/3 of the former. It can be predicted that the larger the offset, the higher the latter.
Performance Optimization:
Based on the high perform
100 data in the class table, the return is 0 start 90 data, i.e. 0 to (100-10)Third, Performance3.1, basic 1, offset is relatively small time. SELECT * from Yanxue8_visit limit 10, 10 runs multiple times, time remains between 0.0004-0.0005 select*from yanxue8_visit Where vid >= ( Selectvidfrom yanxue8_visit Order by vid limit 10,1) limit 10 runs multiple times, The time remains between 0.0005 and 0.0006, mostly 0.0006 conclusions: When offset offsets are smaller, direct use of limit is preferre
that the maximum number of record rows is returned:Mysql> select * from Table limit 5; // retrieve the first five record rows // In other words, limit N is equivalent to limit 0, N. Note the differences between limit 10 and limit 9 and 1: for example, 1.Select * From Cyclopedia where ID> = (Select max (ID) from (Select ID from Cyclopedia order by ID limit 90001) As TMP) Limit 100; 2.Select * From
returned:Mysql> SELECT * from table LIMIT 5; Retrieve the first 5 rows of recordsIn other words, LIMIT n is equivalent to LIMIT 0,n.Note the differences between limit 10 and limit 9,1:For example:1.
Copy Code code as follows:
Select * FROM Cyclopedia Where id>= (
Select Max (ID) from (
Select ID from Cyclopedia order by ID limit 90001
) as TMP
) limit 100;
2.
Copy Co
efficient paging!In this example, I reflect on a point: for large systems, PHP must not use the framework, especially that even SQL statements can not see the framework! Because the beginning of my lightweight framework almost crashed! Only for the rapid development of small applications, for Erp,oa, large web sites, data layer including logic layer of things can not use the framework. If the programmer loses control of the SQL statement, the risk of the project will increase exponentially! Esp
Cyclopedia Where ID>= (
Select Max (ID) from (
Select ID from Cyclopedia Order by ID limit 90001
) as TMP
) limit 100;
Select * FROM Cyclopedia Where ID>= (
Select Max (ID) from (
Select ID from Cyclopedia Order by ID limit 90000,1
) as TMP
) limit 100;
The same is taken 90,00
SELECT * FROM Yanxue8_visit limit 10000,10
Run multiple times and keep time at around 0.0187
Select * from Yanxue8_visit Where vid >= (
Select vid from Yanxue8_visit Order by vid limit 10000,1
) Limit 10
Run several times, the time remains around 0.0061, only the former 1/3. You can expect the larger the offset, the better the latter.Attached Original:SELECT * FROM Table LIMIT 5, 10; #返回第6-15 rows of dataSELECT * FROM table LIMIT 5; #返回前5行SELECT * FROM table
best performance. The performance difference caused by an index can be thousands of thousand! Performance optimization:Based on the high performance of limit in MySQL5.0, I have a new understanding of data paging. 1.Select * FROM Cyclopedia Where id>= (Select Max (ID) from (Select ID from Cyclopedia Order by ID limit 90001) as TMP) limit 100; 2.Select * FROM Cyclopedia
MySQL LIMIT and paging optimization bitsCN.com
Select * from table LIMIT 5, 10; # return data in rows 6-15 select * from table LIMIT 5; # return the first 5 rows select * from table LIMIT; # return the first 5 rows
Performance Optimization:
Based on the high performance of limit in MySQL5.0, I have a new understanding of data paging. 1. select * From cyclopedia Where ID> = (Select Max (ID) From (Select ID From cy
Cyclopedia Where id>= (Select Max (ID) from (Select ID from Cyclopedia order by ID limit 90001) as TMP) limit 100;
2.Select * FROM Cyclopedia Where id>= (Select Max (ID) from (Select ID from Cyclopedia order by ID limit 90000,1) as TMP) limit 100;
Also take 90,000 after 100 records, the 1th sentence is fast or 2nd s
retrieve all record rows from an offset to the end of the record set, you can specify the second parameter-1:
Mysql> select * from table limit 95,-1; // retrieves 96-last records.
// If only one parameter is specified, it indicates the maximum number of record rows returned:
Mysql> select * from table limit 5; // retrieve the first five record rows
// In other words, limit n is equivalent to limit 0, n.
Note the differences between limit 10 and limit 9 and 1:
For example:
1.
Select * from
specified, it indicates the maximum number of record rows returned:
Mysql> SELECT * FROM table LIMIT 5; // retrieve the first five record rows
// In other words, LIMIT n is equivalent to LIMIT 0, n.
Note the differences between limit 10 and limit 9 and 1:
For example:
1.
Select * From cyclopedia Where ID> = (Select Max (ID) From (Select ID From cyclopedia Order By ID limit 90001) As tmp) Limit
SELECT * FROM table limit [offset,] rows | Rows Offset Offset
The limit clause can be used to force a SELECT statement to return the specified number of records. Limit accepts one or two numeric parameters. parameter must be an integer constant. Given two parameters, the first parameter specifies the offset of the first row to return the record, and the second parameter specifies the maximum number of rows to be returned. The initial record line offset is 0 (instead of 1): For compatibility wit
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.